﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace DC2010.Tools
{
    public partial class FileTextBox : UserControl
    {
        public event EventHandler InnerTextChanged;

        public FileTextBox()
        {
            InitializeComponent();
            textBox1.TextChanged += new EventHandler(textBox1_TextChanged);
        }

        void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (InnerTextChanged!=null)
                InnerTextChanged(sender, e);
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                openFileDialog1.ShowDialog();
                textBox1.Text = openFileDialog1.FileName;
            }
        }

        public string InnerText
        {
            get
            {
                return textBox1.Text;
            }
            set
            {
                textBox1.Text = value;
            }
        }

        public string PromptText 
        {
            get
            {
                return textBox1.PromptText;
            }
            set
            {
                textBox1.PromptText = value;
            }
        }


        private void textBox1_MouseHover(object sender, EventArgs e)
        {
            this.textBox1.BackColor = Color.Aqua;
        }

        private void textBox1_MouseLeave(object sender, EventArgs e)
        {
            this.textBox1.BackColor = Color.White;
        }
    }
}
